<template>
  <div class="creator-center">
    <!-- 头部栏 -->
    <HeaderComponent 
      :isLoggedIn="isLoggedIn"
      :userInfo="userInfo"
      :showUserPanel="showUserPanel"
      @open-login="$emit('open-login')"
      @toggle-user-panel="$emit('toggle-user-panel')"
      @logout="$emit('logout')"
    />
    
    <!-- 主布局 -->
    <div class="main-layout">
      <!-- 左侧导航栏 -->
      <aside class="creator-sidebar">
        <div class="sidebar-header">
          <h3>创作者中心</h3>
        </div>
        <ul class="creator-nav">
          <li class="nav-item active">
            <a href="#" class="nav-link">
              <span class="nav-icon">📊</span>
              <span>数据概览</span>
            </a>
          </li>
          <li class="nav-item">
            <a href="#" class="nav-link">
              <span class="nav-icon">📝</span>
              <span>内容管理</span>
            </a>
          </li>
          <li class="nav-item">
            <a href="#" class="nav-link">
              <span class="nav-icon">💬</span>
              <span>互动管理</span>
            </a>
          </li>
          <li class="nav-item">
            <a href="#" class="nav-link">
              <span class="nav-icon">🎯</span>
              <span>创作工具</span>
            </a>
          </li>
          <li class="nav-item">
            <a href="#" class="nav-link">
              <span class="nav-icon">📈</span>
              <span>数据中心</span>
            </a>
          </li>
          <li class="nav-item">
            <a href="#" class="nav-link">
              <span class="nav-icon">⚙️</span>
              <span>创作设置</span>
            </a>
          </li>
        </ul>
      </aside>
      
      <!-- 右侧内容区 -->
      <main class="creator-content">
        <!-- 个人主页信息 -->
        <div class="profile-info">
          <div class="profile-header">
            <div class="profile-avatar">
              <img :src="userInfo.avatar || '/touxiang.jpg'" alt="用户头像" />
            </div>
            <div class="profile-details">
              <h3 class="profile-name">{{ userInfo.nickname || '用户034422292787' }}</h3>
              <div class="profile-stats">
                <div class="stat-item">
                  <span class="stat-number">0</span>
                  <span class="stat-label">粉丝</span>
                </div>
                <div class="stat-divider">|</div>
                <div class="stat-item">
                  <span class="stat-number">6</span>
                  <span class="stat-label">关注</span>
                </div>
                <div class="stat-divider">|</div>
                <div class="stat-item">
                  <span class="stat-number">0</span>
                  <span class="stat-label">掘力值</span>
                </div>
                <div class="stat-divider">|</div>
                <div class="stat-item">
                  <span class="stat-number">0</span>
                  <span class="stat-label">天</span>
                  <span class="stat-sublabel">在掘金创作的第</span>
                </div>
              </div>
            </div>
            <div class="profile-actions">
              <router-link to="/write-article" class="write-article-btn">
                <span class="btn-icon">✏️</span>
                写文章
              </router-link>
            </div>
          </div>
        </div>
        
        <div class="content-header">
          <h2>数据概览</h2>
          <p>查看您的创作数据和表现</p>
        </div>
        
        <!-- 数据卡片 -->
        <div class="stats-grid">
          <div class="stat-card">
            <div class="stat-icon">📝</div>
            <div class="stat-info">
              <div class="stat-number">0</div>
              <div class="stat-label">发布文章</div>
            </div>
          </div>
          
          <div class="stat-card">
            <div class="stat-icon">👀</div>
            <div class="stat-info">
              <div class="stat-number">0</div>
              <div class="stat-label">文章阅读数</div>
            </div>
          </div>
          
          <div class="stat-card">
            <div class="stat-icon">👍</div>
            <div class="stat-info">
              <div class="stat-number">0</div>
              <div class="stat-label">文章点赞数</div>
            </div>
          </div>
          
          <div class="stat-card">
            <div class="stat-icon">💬</div>
            <div class="stat-info">
              <div class="stat-number">0</div>
              <div class="stat-label">文章评论数</div>
            </div>
          </div>
          
          <div class="stat-card">
            <div class="stat-icon">📊</div>
            <div class="stat-info">
              <div class="stat-number">0</div>
              <div class="stat-label">文章收藏数</div>
            </div>
          </div>
          
          <div class="stat-card">
            <div class="stat-icon">👥</div>
            <div class="stat-info">
              <div class="stat-number">0</div>
              <div class="stat-label">文章分享数</div>
            </div>
          </div>
        </div>
        
        <!-- 创作任务 -->
        <div class="creator-tasks">
          <h3>创作任务</h3>
          <div class="task-grid">
            <div class="task-card">
              <div class="task-header">
                <h4>首次发布文章</h4>
                <span class="task-reward">奖励 10000 矿石</span>
              </div>
              <p class="task-desc">发布您的第一篇技术文章，开启创作之旅</p>
              <button class="task-btn">去完成</button>
            </div>
            
            <div class="task-card">
              <div class="task-header">
                <h4>首次发布沸点</h4>
                <span class="task-reward">奖励 5000 矿石</span>
              </div>
              <p class="task-desc">分享您的技术见解或日常思考</p>
              <button class="task-btn">去完成</button>
            </div>
          </div>
        </div>
      </main>
    </div>
  </div>
</template>

<script>
import HeaderComponent from '@/components/HeaderComponent.vue'

export default {
  name: 'CreatorCenter',
  components: {
    HeaderComponent
  },
  props: {
    isLoggedIn: {
      type: Boolean,
      default: false
    },
    userInfo: {
      type: Object,
      default: () => ({})
    },
    showUserPanel: {
      type: Boolean,
      default: false
    }
  },
  emits: ['open-login', 'toggle-user-panel', 'logout']
}
</script>

<style scoped>
.creator-center {
  min-height: 100vh;
  background-color: #f4f5f5;
}

.main-layout {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  gap: 24px;
  padding: 24px;
}

/* 左侧导航栏 */
.creator-sidebar {
  width: 240px;
  background: white;
  border-radius: 8px;
  padding: 0;
  height: fit-content;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #e4e6eb;
}

.sidebar-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1d2129;
}

.creator-nav {
  list-style: none;
  margin: 0;
  padding: 12px 0;
}

.nav-item {
  margin: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  text-decoration: none;
  color: #515767;
  transition: all 0.2s;
}

.nav-link:hover {
  background-color: #f2f3f5;
  color: #1e80ff;
}

.nav-item.active .nav-link {
  background-color: #e8f3ff;
  color: #1e80ff;
  border-right: 3px solid #1e80ff;
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

/* 右侧内容区 */
.creator-content {
  flex: 1;
  background: white;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.content-header {
  margin-bottom: 32px;
}

.content-header h2 {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 600;
  color: #1d2129;
}

.content-header p {
  margin: 0;
  color: #86909c;
  font-size: 14px;
}

/* 个人主页信息 */
.profile-info {
  background: white;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-details {
  flex: 1;
}

.profile-name {
  margin: 0 0 12px 0;
  font-size: 20px;
  font-weight: 600;
  color: #1d2129;
}

.profile-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  color: #86909c;
  font-size: 14px;
}

.stat-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.stat-number {
  font-weight: 600;
  color: #1d2129;
}

.stat-label {
  color: #86909c;
}

.stat-sublabel {
  color: #86909c;
  margin-left: 4px;
}

.stat-divider {
  color: #e4e6eb;
}

.profile-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.write-article-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #1e80ff, #1171ee);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(30, 128, 255, 0.2);
}

.write-article-btn:hover {
  background: linear-gradient(135deg, #0969da, #0550ae);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(30, 128, 255, 0.3);
  color: white;
  text-decoration: none;
}

.write-article-btn .btn-icon {
  font-size: 16px;
}

/* 数据卡片网格 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e4e6eb;
}

.stat-icon {
  font-size: 32px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 8px;
}

.stat-info {
  flex: 1;
}

.stat-number {
  font-size: 24px;
  font-weight: 600;
  color: #1d2129;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 14px;
  color: #86909c;
}

/* 创作任务 */
.creator-tasks h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
  color: #1d2129;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.task-card {
  padding: 20px;
  border: 1px solid #e4e6eb;
  border-radius: 8px;
  background: white;
}

.task-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.task-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #1d2129;
}

.task-reward {
  font-size: 12px;
  color: #1e80ff;
  background: #e8f3ff;
  padding: 4px 8px;
  border-radius: 4px;
}

.task-desc {
  margin: 0 0 16px 0;
  font-size: 14px;
  color: #86909c;
  line-height: 1.5;
}

.task-btn {
  background: #1e80ff;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.task-btn:hover {
  background: #1664d9;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .main-layout {
    flex-direction: column;
    padding: 16px;
  }
  
  .creator-sidebar {
    width: 100%;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .task-grid {
    grid-template-columns: 1fr;
  }
}
</style>